package com.hzjq.fxlib.util

import android.text.TextUtils
import com.hzjq.core.bean.CapEntity
import com.hzjq.core.bean.ErrorCapEntity

class CapCompare {

    companion object {

        /**
         * 设置孔号，请在线程中自行调用
         */
        fun compareSetHole(dest: List<CapEntity>, src: List<CapEntity>) {
            dest.forEach { cap ->
                breaking@ run {
                    src.forEach {
                        if (TextUtils.equals(it.uid, cap.uid)) {
                            cap.holeNumber = it.holeNumber
                            cap.areaNumber = it.areaNumber
                            cap.rowNumber = it.rowNumber
                            return
                        }
                    }
                }
            }
        }

        /**
         * 设置孔号，请在线程中自行调用
         */
        fun compareSetHole(dest: CapEntity, src: List<CapEntity>) {
            src.forEach {
                if (TextUtils.equals(it.uid, dest.uid)) {
                    dest.holeNumber = it.holeNumber
                    dest.areaNumber = it.areaNumber
                    dest.rowNumber = it.rowNumber
                    return
                }
            }
        }

        /**
         * 设置孔号，请在线程中自行调用
         */
        fun compareSetHole(dest: ErrorCapEntity, src: List<ErrorCapEntity>) {
            src.forEach {
                if (TextUtils.equals(it.cap!!.uid, dest.cap!!.uid)) {
                    dest.cap!!.holeNumber = it.cap!!.holeNumber
                    dest.cap!!.areaNumber = it.cap!!.areaNumber
                    dest.cap!!.rowNumber = it.cap!!.rowNumber
                    return
                }
            }
        }


        /**
         * 设置孔号，请在线程中自行调用
         */

        fun compareSetErrorHole(dest: ErrorCapEntity, src: List<CapEntity>) {
            src.forEach {
                if (TextUtils.equals(it.uid, dest.cap!!.uid)) {
                    dest.cap!!.holeNumber = it.holeNumber
                    dest.cap!!.areaNumber = it.areaNumber
                    dest.cap!!.rowNumber = it.rowNumber
                    return
                }
            }
        }
    }
}